using System;
using System.Web.Http;
using Thinktecture.IdentityModel.Http.Cors.WebApi;
using WebActivatorEx;

[assembly: PreApplicationStartMethod(typeof(LeonardoNews.Server.App_Start.CorsConfig), "PreStart")]

namespace LeonardoNews.Server.App_Start
{
    public static class CorsConfig
    {
        public static void PreStart()
        {
            GlobalConfiguration.Configuration.MessageHandlers.Add(new RedRocket.WebApi.Cors.CorsHandler());
        }

        public static void RegisterCors(HttpConfiguration httpConfig)
        {
            WebApiCorsConfiguration corsConfig = new WebApiCorsConfiguration();
            corsConfig.RegisterGlobal(httpConfig);
            corsConfig.ForAllOrigins().AllowAllMethodsAndAllRequestHeaders();

        }
    }
}

